package org.edu.modules.jxgz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.edu.modules.jxgz.entity.VeJwSkjh;
import org.edu.modules.jxgz.entity.VeJwSkjhmx;
import org.edu.modules.jxgz.mapper.VeJwSkjhMapper;
import org.edu.modules.jxgz.service.IVeJwSkjhService;
import org.edu.modules.jxgz.service.IVeJwSkjhmxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: ve_jw_skjh
 * @Author: jeecg-boot
 * @Date:   2021-05-26
 * @Version: V1.0
 */
@Service
public class VeJwSkjhServiceImpl extends ServiceImpl<VeJwSkjhMapper, VeJwSkjh> implements IVeJwSkjhService {

    @Autowired
    private IVeJwSkjhmxService veJwSkjhmxService;

    @Override
    public VeJwSkjh getByJxrwId(Integer jxrwId) {
        LambdaQueryWrapper<VeJwSkjh> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(VeJwSkjh::getJxrwid, jxrwId);
        return getBaseMapper().selectOne(wrapper);
    }

    @Override
    public void deleteByIdAndDetail(Integer id) {
        // 删除授课计划
        getBaseMapper().deleteById(id);
        // 删除授课计划详情
        LambdaQueryWrapper<VeJwSkjhmx> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(VeJwSkjhmx::getSkjhid, id);
        veJwSkjhmxService.remove(wrapper);
    }
}
